home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume13 / unclutter / patch1 < prev    next >
Encoding:
Text File  |  1991-07-16  |  15.6 KB  |  476 lines

  1. Path: uunet!cs.utexas.edu!sun-barr!cronkite.Central.Sun.COM!jethro!exodus!cetia1.cetia.fr
  2. From: mmm@cetia1.cetia.fr (Mark Martin)
  3. Newsgroups: comp.sources.x
  4. Subject: v13i078: unclutter, Patch1, Part01/01
  5. Message-ID: <16947@exodus.Eng.Sun.COM>
  6. Date: 16 Jul 91 23:48:01 GMT
  7. References: <csx-13i078-unclutter@uunet.UU.NET>
  8. Sender: news@exodus.Eng.Sun.COM
  9. Lines: 464
  10. Approved: argv@sun.com
  11.  
  12. Submitted-by: Mark Martin <mmm@cetia1.cetia.fr>
  13. Posting-number: Volume 13, Issue 78
  14. Archive-name: unclutter/patch1
  15. Patch-To: unclutter: Volume 13, Issue 5
  16.  
  17. This is a shar of a patch file to unclutter version and patchlevel 2.
  18. It introduces a -visible option to ignore the strange visibility events
  19. that are being generated by some servers when the cursor-grabbing
  20. input-only window is created, and which cause the cursor to flicker
  21. but not disappear.  It also has a -not option to exclude specific windows
  22. from the list to unclutter.  I dont envisage any further developments.
  23.  
  24. Thanks for their help with "remote debugging" via xscope of various servers to
  25.     dave edsall@iastate.edu
  26.     Roland McGrath <roland@geech.gnu.ai.mit.edu>
  27.     Rainer Sinkwitz <sinkwitz@ifi.unizh.ch>
  28.     Michael L. Brown astroatc!ftms!brown@cs.wisc.edu
  29.     patti@hosehead.hf.intel.com
  30. and, for vroot.h, Andreas Stolcke <stolcke@ICSI.Berkeley.EDU>
  31. and to all those who tested various development versions sent by mail.
  32.  
  33. Mark M Martin            mmm@cetia.fr
  34. Cetia (BP 244),            inria!cetia!mmm
  35. 150 rue Marcelin Berthelot,    tel +33 94 08 80 00
  36. ZI Toulon Est,            fax +33 94 08 80 01
  37. 83078 TOULON CEDEX 9, France
  38. ------
  39. #! /bin/sh
  40. # This is a shell archive, meaning:
  41. # 1. Remove everything above the #! /bin/sh line.
  42. # 2. Save the resulting text in a file.
  43. # 3. Execute the file with /bin/sh (not csh) to create the files:
  44. #    patches.3
  45. # This archive created: Tue Jun 18 18:37:32 FDT 1991
  46. # By: mmm
  47. # Part 1 of 1
  48. PATH=/bin:$PATH export PATH
  49. if test -f 'patches.3'
  50. then    echo "shar: will not overwrite existing file patches.3"
  51. else    echo "shar: extracting patches.3 (13123 chars)"
  52.     sed 's/^X//' <<\END-OF-FILE! >'patches.3'
  53. Xdiff -r -c old/README unclutter/README
  54. X*** old/README    Tue Jun 18 18:15:51 1991
  55. X--- unclutter/README    Thu May 30 12:30:29 1991
  56. X***************
  57. X*** 16,22 ****
  58. X  will apparently leave the window, even though its x y position doesnt change.
  59. X  
  60. X  The first version of this program used a grab to remove the cursor.
  61. X! This methid is still available with a "-grab" option to the program.
  62. X  
  63. X  The program is released into the public domain.  Only the considerate
  64. X  will leave credit for the author.
  65. X--- 16,31 ----
  66. X  will apparently leave the window, even though its x y position doesnt change.
  67. X  
  68. X  The first version of this program used a grab to remove the cursor.
  69. X! This method is still available with a "-grab" option to the program.
  70. X! 
  71. X! Thanks for their help with "remote debugging" with xscope of various servers to
  72. X!     dave edsall@iastate.edu
  73. X!     Roland McGrath <roland@geech.gnu.ai.mit.edu>
  74. X!     Rainer Sinkwitz <sinkwitz@ifi.unizh.ch>
  75. X!     Michael L. Brown astroatc!ftms!brown@cs.wisc.edu
  76. X!     patti@hosehead.hf.intel.com
  77. X! and, for vroot.h, Andreas Stolcke <stolcke@ICSI.Berkeley.EDU>
  78. X! and to all those who tested various development versions sent by mail.
  79. X  
  80. X  The program is released into the public domain.  Only the considerate
  81. X  will leave credit for the author.
  82. Xdiff -r -c old/patchlevel.h unclutter/patchlevel.h
  83. X*** old/patchlevel.h    Tue Jun 18 18:15:53 1991
  84. X--- unclutter/patchlevel.h    Tue Jun 18 18:11:50 1991
  85. X***************
  86. X*** 4,8 ****
  87. X   * level 1: -grab option to use old method, new method creates small input
  88. X   * only sub-window. (distributed by mail only, not posted)
  89. X   * level 2: use Andreas Stolcke's vroot.h for tvtwm and similar winmans.
  90. X   */
  91. X! #define PATCHLEVEL 2
  92. X--- 4,10 ----
  93. X   * level 1: -grab option to use old method, new method creates small input
  94. X   * only sub-window. (distributed by mail only, not posted)
  95. X   * level 2: use Andreas Stolcke's vroot.h for tvtwm and similar winmans.
  96. X+  * level 3: -not option takes list of windows to avoid and -visible ignores
  97. X+  *        visibility events for some servers.
  98. X   */
  99. X! #define PATCHLEVEL 3
  100. Xdiff -r -c old/unclutter.c unclutter/unclutter.c
  101. X*** old/unclutter.c    Tue Jun 18 18:15:47 1991
  102. X--- unclutter/unclutter.c    Tue Jun 18 18:11:50 1991
  103. X***************
  104. X*** 8,13 ****
  105. X--- 8,16 ----
  106. X   * shapes depending on whether they have pointer focus or not.
  107. X   * Whereas version 1 did a grab cursor, version 2 creates a small subwindow.
  108. X   * This may work better with some window managers.
  109. X+  * Some servers return a Visibility event when the subwindow is mapped.
  110. X+  * Sometimes this is Unobscured, or even FullyObscured. Ignore these and
  111. X+  * rely on LeaveNotify events.
  112. X   * Mark M Martin. cetia 1991  mmm@cetia.fr
  113. X   */
  114. X  #include <X11/Xos.h>
  115. X***************
  116. X*** 30,36 ****
  117. X      -grab            use grabpointer method not createwindow\n\
  118. X      -reset            reset the timer whenever cursor becomes\n\
  119. X                      visible even if it hasn't moved\n\
  120. X!      -root                   apply to cursor on root window too");
  121. X  }
  122. X  
  123. X  #define ALMOSTEQUAL(a,b) (abs(a-b)<=jitter)
  124. X--- 33,42 ----
  125. X      -grab            use grabpointer method not createwindow\n\
  126. X      -reset            reset the timer whenever cursor becomes\n\
  127. X                      visible even if it hasn't moved\n\
  128. X!      -root                   apply to cursor on root window too\n\
  129. X!      -visible               ignore visibility events\n\
  130. X!     -not names...        dont apply to windows whose wm-name begins.\n\
  131. X!                 (must be last argument)");
  132. X  }
  133. X  
  134. X  #define ALMOSTEQUAL(a,b) (abs(a-b)<=jitter)
  135. X***************
  136. X*** 51,61 ****
  137. X      (*defaulthandler)(display,error);
  138. X  }
  139. X  
  140. X  main(argc,argv)char **argv;{
  141. X      Display *display;
  142. X      Cursor cursor;
  143. X      int screen,oldx,oldy = -99;
  144. X!     int doroot = 0, jitter = 0, idletime = 5, usegrabmethod = 0, waitagain = 0;
  145. X      Window root;
  146. X      Pixmap cursormask;
  147. X      XGCValues xgc;
  148. X--- 57,93 ----
  149. X      (*defaulthandler)(display,error);
  150. X  }
  151. X  
  152. X+ char **names;    /* -> argv list of names to avoid */
  153. X+ 
  154. X+ /*
  155. X+  * return true if window has a wm_name and the start of it matches
  156. X+  * one of the given names to avoid
  157. X+  */
  158. X+ nameinlist(display,window)
  159. X+ Display *display;
  160. X+ Window window;
  161. X+ {
  162. X+     char **cpp;
  163. X+     char *name;
  164. X+ 
  165. X+     if(names==0)return 0;
  166. X+     if(XFetchName (display, window, &name)){
  167. X+     for(cpp = names;*cpp!=0;cpp++){
  168. X+         if(strncmp(*cpp,name,strlen(*cpp))==0)
  169. X+         break;
  170. X+     }
  171. X+     XFree(name);
  172. X+     return(*cpp!=0);
  173. X+     }
  174. X+     return 0;
  175. X+ }    
  176. X+ 
  177. X  main(argc,argv)char **argv;{
  178. X      Display *display;
  179. X      Cursor cursor;
  180. X      int screen,oldx,oldy = -99;
  181. X!     int doroot = 0, jitter = 0, idletime = 5, usegrabmethod = 0, waitagain = 0,
  182. X!     dovisible = 1;
  183. X      Window root;
  184. X      Pixmap cursormask;
  185. X      XGCValues xgc;
  186. X***************
  187. X*** 80,85 ****
  188. X--- 112,124 ----
  189. X          usegrabmethod = 1;
  190. X      }else if(strcmp(*argv,"-reset")==0){
  191. X          waitagain = 1;
  192. X+     }else if(strcmp(*argv,"-visible")==0){
  193. X+         dovisible = 0;
  194. X+     }else if(strcmp(*argv,"-not")==0){
  195. X+         /* take rest of srg list */
  196. X+         names = ++argv;
  197. X+         if(*names==0)names = 0;    /* no args follow */
  198. X+         argc = 0;
  199. X      }else if(strcmp(*argv,"-display")==0){
  200. X          argc--,argv++;
  201. X          if(argc<0)usage();
  202. X***************
  203. X*** 110,115 ****
  204. X--- 149,155 ----
  205. X      Window dummywin,windowin;
  206. X      int rootx,rooty,winx,winy;
  207. X      unsigned int modifs;
  208. X+     Window lastwindowavoided = None;
  209. X      
  210. X      /* wait for pointer to not move and no buttons down */
  211. X      while(1){
  212. X***************
  213. X*** 120,126 ****
  214. X          }else if((!doroot && windowin==None) || (modifs & ANYBUTTON) ||
  215. X               !(ALMOSTEQUAL(rootx,oldx) && ALMOSTEQUAL(rooty,oldy))){
  216. X          oldx = rootx, oldy = rooty;
  217. X!         }else break;
  218. X          sleep(idletime);
  219. X      }
  220. X      /* wait again next time */
  221. X--- 160,187 ----
  222. X          }else if((!doroot && windowin==None) || (modifs & ANYBUTTON) ||
  223. X               !(ALMOSTEQUAL(rootx,oldx) && ALMOSTEQUAL(rooty,oldy))){
  224. X          oldx = rootx, oldy = rooty;
  225. X!         }else if(windowin==None){
  226. X!         windowin = root;
  227. X!         break;
  228. X!         }else if(windowin!=lastwindowavoided){
  229. X!         /* descend tree of windows under cursor to bottommost */
  230. X!         Window childin;
  231. X!         int toavoid = xFalse;
  232. X!         lastwindowavoided = childin = windowin;
  233. X!         do{
  234. X!             windowin = childin;
  235. X!             if(nameinlist (display, windowin)){
  236. X!             toavoid = xTrue;
  237. X!             break;
  238. X!             }
  239. X!         }while(XQueryPointer(display, windowin, &dummywin,
  240. X!              &childin, &rootx, &rooty, &winx, &winy, &modifs)
  241. X!                && childin!=None);
  242. X!         if(!toavoid){
  243. X!             lastwindowavoided = None;
  244. X!             break;
  245. X!         }
  246. X!         }
  247. X          sleep(idletime);
  248. X      }
  249. X      /* wait again next time */
  250. X***************
  251. X*** 146,165 ****
  252. X          Window cursorwindow;
  253. X          Window childin;
  254. X          
  255. X-         /* descend tree of windows under cursor to bottommost */
  256. X-         if(windowin!=None)
  257. X-         while(XQueryPointer(display, windowin, &dummywin, &childin,
  258. X-                     &rootx, &rooty, &winx, &winy, &modifs)
  259. X-               && childin!=None)
  260. X-             windowin = childin;
  261. X-         else windowin = root;
  262. X          /* create small input-only window under cursor
  263. X           * as a sub window of the window currently under the cursor
  264. X           */
  265. X          attributes.event_mask = LeaveWindowMask |
  266. X-             VisibilityChangeMask |
  267. X              StructureNotifyMask |
  268. X              FocusChangeMask;
  269. X          attributes.override_redirect = True;
  270. X          attributes.cursor = cursor;
  271. X          cursorwindow = XCreateWindow
  272. X--- 207,220 ----
  273. X          Window cursorwindow;
  274. X          Window childin;
  275. X          
  276. X          /* create small input-only window under cursor
  277. X           * as a sub window of the window currently under the cursor
  278. X           */
  279. X          attributes.event_mask = LeaveWindowMask |
  280. X              StructureNotifyMask |
  281. X              FocusChangeMask;
  282. X+         if(dovisible)
  283. X+         attributes.event_mask |= VisibilityChangeMask;
  284. X          attributes.override_redirect = True;
  285. X          attributes.cursor = cursor;
  286. X          cursorwindow = XCreateWindow
  287. X***************
  288. X*** 187,193 ****
  289. X                 event.type!=CirculateNotify &&
  290. X                 event.type!=ReparentNotify &&
  291. X                 event.type!=DestroyNotify &&
  292. X!                event.type!=VisibilityNotify);
  293. X          /* check if a second unclutter is running cos they thrash */
  294. X          if(event.type==LeaveNotify &&
  295. X             event.xcrossing.window==cursorwindow &&
  296. X--- 242,250 ----
  297. X                 event.type!=CirculateNotify &&
  298. X                 event.type!=ReparentNotify &&
  299. X                 event.type!=DestroyNotify &&
  300. X!                (event.type!=VisibilityNotify ||
  301. X!             event.xvisibility.state==VisibilityUnobscured)
  302. X!                );
  303. X          /* check if a second unclutter is running cos they thrash */
  304. X          if(event.type==LeaveNotify &&
  305. X             event.xcrossing.window==cursorwindow &&
  306. Xdiff -r -c old/unclutter.man unclutter/unclutter.man
  307. X*** old/unclutter.man    Tue Jun 18 18:15:48 1991
  308. X--- unclutter/unclutter.man    Fri May 24 19:13:55 1991
  309. X***************
  310. X*** 14,19 ****
  311. X--- 14,21 ----
  312. X  .RB [ -grab ]
  313. X  .RB [ -reset ]
  314. X  .RB [ -root ]
  315. X+ .RB [ -not ]
  316. X+ .I "name ...
  317. X  .SH DESCRIPTION
  318. X  .B unclutter
  319. X  removes the cursor image from the screen so that it does not
  320. X***************
  321. X*** 50,55 ****
  322. X--- 52,64 ----
  323. X  -root
  324. X  means remove the cursor even if it is on the root background, where in
  325. X  principle it should not be obscuring anything useful.
  326. X+ .TP
  327. X+ -not
  328. X+ is followed by a list of window names where the cursor should not be
  329. X+ removed.
  330. X+ The first few characters of the WM_NAME property on the window need
  331. X+ to match one the listed names.
  332. X+ This argument must be the last on the command line.
  333. X  .SH LIMITATIONS
  334. X  Unfortunately, clients like emacs set different text cursor
  335. X  shapes depending on whether they have pointer focus or not,
  336. X***************
  337. X*** 67,70 ****
  338. X  This situation quickly deteriorates into a fight no one can win, so
  339. X  it is detected when possible and the program gives up.
  340. X  .SH AUTHOR
  341. X! Mark M Martin. cetia 1991. mmm@cetia.fr
  342. X--- 76,79 ----
  343. X  This situation quickly deteriorates into a fight no one can win, so
  344. X  it is detected when possible and the program gives up.
  345. X  .SH AUTHOR
  346. X! Mark M Martin. cetia 24may1991. mmm@cetia.fr
  347. Xdiff -r -c old/vroot.h unclutter/vroot.h
  348. X*** old/vroot.h    Tue Jun 18 18:15:49 1991
  349. X--- unclutter/vroot.h    Fri May 24 19:13:55 1991
  350. X***************
  351. X*** 28,35 ****
  352. X   * after all the X11 header files.  It has been tested on such popular
  353. X   * X clients as xphoon, xfroot, xloadimage, and xaqua.
  354. X   *
  355. X!  * Andreas Stolcke (stolcke@ICSI.Berkeley.EDU), 9/7/90
  356. X!  * minor mods signalled with: mmm and DONTOPTIMISE.
  357. X   */
  358. X  #define DONTOPTIMISE    /* unclutter needs to search from scratch each time */
  359. X  
  360. X--- 28,36 ----
  361. X   * after all the X11 header files.  It has been tested on such popular
  362. X   * X clients as xphoon, xfroot, xloadimage, and xaqua.
  363. X   *
  364. X!  * Andreas Stolcke <stolcke@ICSI.Berkeley.EDU>, 9/7/90
  365. X!  * - replaced all NULL's with properly cast 0's, 5/6/91
  366. X!  * - free children list (suggested by Mark Martin <mmm@cetia.fr>), 5/16/91
  367. X   */
  368. X  #define DONTOPTIMISE    /* unclutter needs to search from scratch each time */
  369. X  
  370. X***************
  371. X*** 40,83 ****
  372. X  VirtualRootWindow(dpy, screen)
  373. X  Display *dpy;
  374. X  {
  375. X!     static Display *save_dpy = (Display *)NULL;
  376. X      static int save_screen = -1;
  377. X!     static Window root = (Window)NULL;
  378. X  
  379. X-     Atom __SWM_VROOT = None;
  380. X-     int i;
  381. X-     Window rootReturn, parentReturn, *children;
  382. X-     unsigned int numChildren;
  383. X- 
  384. X  #ifdef DONTOPTIMISE
  385. X      {
  386. X  #else
  387. X!     if ( dpy != save_dpy || screen != save_screen ) {
  388. X  #endif
  389. X          root = RootWindow(dpy, screen);
  390. X  
  391. X          /* go look for a virtual root */
  392. X          __SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
  393. X!         if(XQueryTree(dpy, root, &rootReturn, &parentReturn,
  394. X!                  &children, &numChildren)){    /* mmm */
  395. X!             for (i = 0; i < numChildren; i++) {
  396. X!             Atom actual_type;
  397. X!             int actual_format;
  398. X!             unsigned long nitems, bytesafter;    /* mmm */
  399. X!             Window *newRoot = NULL;
  400. X  
  401. X!             if (XGetWindowProperty(dpy, children[i], __SWM_VROOT,
  402. X!                 0, 1, False, XA_WINDOW,
  403. X!                 &actual_type, &actual_format,
  404. X!                 &nitems, &bytesafter,
  405. X!                 (unsigned char **) &newRoot) == Success
  406. X!                 && newRoot) {
  407. X!                 root = *newRoot;
  408. X!                 break;
  409. X              }
  410. X!             }
  411. X!             if(children)XFree((char *)children);    /* mmm */
  412. X          }
  413. X          save_dpy = dpy;
  414. X          save_screen = screen;
  415. X      }
  416. X--- 41,86 ----
  417. X  VirtualRootWindow(dpy, screen)
  418. X  Display *dpy;
  419. X  {
  420. X!     static Display *save_dpy = (Display *)0;
  421. X      static int save_screen = -1;
  422. X!     static Window root = (Window)0;
  423. X  
  424. X  #ifdef DONTOPTIMISE
  425. X      {
  426. X  #else
  427. X!     if (dpy != save_dpy || screen != save_screen) {
  428. X  #endif
  429. X+         Atom __SWM_VROOT = None;
  430. X+         int i;
  431. X+         Window rootReturn, parentReturn, *children;
  432. X+         unsigned int numChildren;
  433. X+ 
  434. X          root = RootWindow(dpy, screen);
  435. X  
  436. X          /* go look for a virtual root */
  437. X          __SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
  438. X!         if (XQueryTree(dpy, root, &rootReturn, &parentReturn,
  439. X!                  &children, &numChildren)) {
  440. X!             for (i = 0; i < numChildren; i++) {
  441. X!                 Atom actual_type;
  442. X!                 int actual_format;
  443. X!                 unsigned long nitems, bytesafter;
  444. X!                 Window *newRoot = (Window *)0;
  445. X  
  446. X!                 if (XGetWindowProperty(dpy, children[i],
  447. X!                     __SWM_VROOT, 0, 1, False, XA_WINDOW,
  448. X!                     &actual_type, &actual_format,
  449. X!                     &nitems, &bytesafter,
  450. X!                     (unsigned char **) &newRoot) == Success
  451. X!                     && newRoot) {
  452. X!                     root = *newRoot;
  453. X!                     break;
  454. X!                 }
  455. X              }
  456. X!             if (children)
  457. X!                 XFree((char *)children);
  458. X          }
  459. X+ 
  460. X          save_dpy = dpy;
  461. X          save_screen = screen;
  462. X      }
  463. END-OF-FILE!
  464.     if test 13123 -ne "`wc -c <'patches.3'`"
  465.     then    echo "shar: error transmitting patches.3 (13123 characters)"
  466.     fi
  467. fi
  468. echo 'end of shar part 1 of 1'
  469. exit 0
  470.  
  471. --
  472. Dan Heller
  473. O'Reilly && Associates       Z-Code Software    Comp-sources-x:
  474. Senior Writer                President          comp-sources-x@uunet.uu.net
  475. argv@ora.com                 argv@zipcode.com
  476.